﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SAR.Pages;

namespace SAR
{
    public partial class ChengXiangChuLi0 : BasePageClass, PageWithParent
	{
		public ChengXiangChuLi0()
		{
			this.InitializeComponent();
            this.model1Grid.Visibility = Visibility.Visible;
            this.model2Grid.Visibility = Visibility.Hidden;

			// 在此点之下插入创建对象所需的代码。

		}

        #region BasePageClass Members


     
        

        public bool PreClick()
        {
            return true;
        }

        //设置本次选择模式
        public bool NextClick()
        {
            if (this.modelChooseList.SARComboBox.SelectedIndex == 0)
            {
                parentCtr.ModelType = 0;
            }
            else
            {
                parentCtr.ModelType = 1;
            }
            return true;
        }

        //父亲引用
        private ChengXiangChuLiPageControl parentCtr;
        public void SetParent(Page parent)
        {
            this.parentCtr = parent as ChengXiangChuLiPageControl;

            //记忆上次选择模式
            if (parentCtr.ModelType == 0)
            {
                this.modelChooseList.SARComboBox.SelectedIndex = 0;
            }else
            {
                this.modelChooseList.SARComboBox.SelectedIndex = 1;
            }
           
        }

        #endregion

        //模式选择变化事件
        private void modelChooseList_SARSelectionChanged(int selectedIndex)
        {
            if (selectedIndex == 0)
            {
                if (this.model1Grid != null)
                {
                    this.model1Grid.Visibility = Visibility.Visible;
                }
                if (this.model2Grid != null)
                {
                    this.model2Grid.Visibility = Visibility.Hidden;
                }
                if (parentCtr != null)
                {
                    parentCtr.ModelType = 0;
                }
                
            }else
            {
                if (this.model1Grid != null)
                {
                    this.model1Grid.Visibility = Visibility.Hidden;
                }
                if (this.model2Grid != null)
                {
                    this.model2Grid.Visibility = Visibility.Visible;
                }
                if (parentCtr != null)
                {
                    parentCtr.ModelType = 1;
                }
            }
        }
    }
}